﻿using Cinchoo.Core.Shell;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cinchoo.Core.Configuration.JSON.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            AppSettings appSettings = new AppSettings();
            var x = appSettings.Name;

            ChoConsole.PauseLine();
            appSettings.Name = appSettings.Name + "1";
            ChoFramework.Shutdown();
        }
    }

    [ChoJSONConfigurationSection("appSettings", ConfigFilePath = "test.json", Silent = false)]
    public class AppSettings : ChoConfigurableObject
    {
        [ChoPropertyInfo("name", DefaultValue = "Raj")]
        [ChoNotNullOrWhiteSpaceValidator]
        public string Name
        {
            get;
            set;
        }

        [ChoPropertyInfo("address", DefaultValue = "10 River Road, 08837")]
        public string Address;

        [ChoPropertyInfo("Date", DefaultValue = "%%NOW^MM/dd/yyyy HH:mm:ss%%")]
        public DateTime Date;

        protected override void OnAfterConfigurationObjectLoaded()
        {
            Console.WriteLine(ToString());
        }

        protected override void OverrideMetaDataInfo(ChoBaseConfigurationMetaDataInfo metaDataInfo)
        {
            ChoStandardConfigurationMetaDataInfo mi = metaDataInfo as ChoStandardConfigurationMetaDataInfo;
            mi.ConfigFilePath = "test12.json";
            base.OverrideMetaDataInfo(metaDataInfo);
        }
    }
}
